home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_HDF.idb / usr / freeware / include / hdf / mfan.h.z / mfan.h
Encoding:
C/C++ Source or Header  |  1999-01-26  |  14.4 KB  |  373 lines

  1. /****************************************************************************
  2.  * NCSA HDF                                                                 *
  3.  * Software Development Group                                               *
  4.  * National Center for Supercomputing Applications                          *
  5.  * University of Illinois at Urbana-Champaign                               *
  6.  * 605 E. Springfield, Champaign IL 61820                                   *
  7.  *                                                                          *
  8.  * For conditions of distribution and use, see the accompanying             *
  9.  * hdf/COPYING file.                                                        *
  10.  *                                                                          *
  11.  ****************************************************************************/
  12.  
  13. /* $Id: mfan.h,v 1.15 1997/10/21 17:45:06 georgev Exp $ */
  14.  
  15. /*------------------------------------------------------------------------------
  16.  * File:    mfan.h
  17.  * Author:  GeorgeV
  18.  * Purpose: header file for the Multi-file Annotation Interface
  19.  * Invokes: 
  20.  * Contents:
  21.  *          Structure definitions: ANnode, ANentry
  22.  *          Constant definitions:  AN_DATA_LABEL, AN_DATA_DESC
  23.  *          (-moved to hdf.h)      AN_FILE_LABEL, AN_FILE_DESC
  24.  *
  25.  *----------------------------------------------------------------------------*/
  26.  
  27. #ifndef _MFAN_H  /* avoid re-inclusion */
  28. #define _MFAN_H
  29.  
  30. #include "hdf.h"
  31.  
  32. #if 0
  33. /* enumerated types of the varous annotation types 
  34.  * NOTE: moved to hdf.h since they are used by end users. */
  35. typedef enum 
  36.   AN_DATA_LABEL = 0, /* Data label */
  37.   AN_DATA_DESC,      /* Data description */
  38.   AN_FILE_LABEL,     /* File label */
  39.   AN_FILE_DESC       /* File description */
  40. } ann_type;
  41. #endif
  42.  
  43. #ifdef MFAN_C
  44. /* WE ARE IN MAIN ANNOTATION SOURCE FILE "mfan.c" */
  45.  
  46. /* PRIVATE variables and definitions */
  47.  
  48. /* This sturcture is used to find which file the annotation belongs to
  49.  * and use the subsequent file specific annotation 'key' to find the 
  50.  * annotation. The annotation atom group(ANIDGROUP) keeps track of 
  51.  * all anotations across the file. */
  52. typedef struct ANnode
  53. {
  54.   int32   file_id;  /* which file this annotation belongs to */
  55.   int32   ann_key;  /* type/ref: used to find annotation in corresponding
  56.                        TBBT in filerec_t->tree[]. */
  57.   intn    new_ann;  /* flag */
  58. } ANnode;
  59.  
  60. /*
  61.  * This structure is an entry in the label/desc tree
  62.  * for a label/desc in the file, it gives the ref of the label/desc,
  63.  * and the tag/ref of the data item to which the label/desc relates 
  64.  * The filerec_t->an_tree[] TBBT members will contain these entries.
  65.  **/
  66. typedef struct ANentry
  67. {
  68.   int32   ann_id;      /* annotation id */
  69.   uint16  annref;      /* ref of annotation */
  70.   uint16  elmtag;      /* tag of data */
  71.   uint16  elmref;      /* ref of data */
  72. } ANentry;
  73.  
  74.  
  75. /* This is the size of the hash tables used for annotation IDs */
  76. #define ANATOM_HASH_SIZE    64
  77.  
  78. /* Used to create unique 32bit keys from annotation type and reference number 
  79.  *  This key is used to add nodes to a corresponding TBBT in 
  80.  *  filrerec_t->an_tree[]. 
  81.  *  ----------------------------
  82.  *  | type(16bits) | ref(16bits) |
  83.  *  -----------------------------*/
  84. #define AN_CREATE_KEY(t,r) ((((int32)t & 0xffff) << 16) | r)
  85.  
  86. /* Obtain Reference number from key */
  87. #define AN_KEY2REF(k)      ((uint16)((int32)k & 0xffff))
  88.  
  89. /* Obtain Annotation type from key */
  90. #define AN_KEY2TYPE(k)     ((int32)((int32)k >> 16))
  91.  
  92. #else /* !MFAN_C */
  93. /* WE are NOT in main ANNOTATION source file
  94.  * Nothing EXPORTED except Public fcns */
  95.  
  96.  
  97. /******************************************************************************
  98.  NAME
  99.     ANdestroy -- Un-Initialize Annotation Interface
  100.  
  101.  DESCRIPTION
  102.     Unallocates global annotaton node list and file list.
  103.  
  104.  RETURNS
  105.     SUCCEED or FAIL
  106. *******************************************************************************/
  107. extern intn ANdestroy(void);
  108.  
  109. /******************************************************************************
  110.  NAME
  111.    ANstart - open file for annotation handling
  112.  
  113.  DESCRIPTION
  114.    Start annotation handling on the file return a annotation ID to the file.
  115.  
  116.  RETURNS
  117.    A file ID or FAIL.
  118. *******************************************************************************/
  119. extern int32 ANstart(int32 file_id /* IN: file to start annotation access on */);
  120.  
  121. /******************************************************************************
  122.  NAME
  123.    ANfileinfo - Report high-level information about the ANxxx interface for a given file.
  124.  
  125.  DESCRIPTION
  126.    Reports general information about the number of file and object(i.e. data)
  127.    annotations in the file. This routine is generally used to find
  128.    the range of acceptable indices for ANselect calls.
  129.  
  130.  RETURNS
  131.    Returns SUCCEED if successful and FAIL othewise
  132.  
  133. *******************************************************************************/
  134. extern intn  ANfileinfo(int32 an_id,         /* IN:  annotation interface id */
  135.                         int32 *n_file_label, /* OUT: the # of file labels */
  136.                         int32 *n_file_desc,  /* OUT: the # of file descriptions */
  137.                         int32 *n_obj_label,  /* OUT: the # of object labels */ 
  138.                         int32 *n_obj_desc    /* OUT: the # of object descriptions */);
  139.  
  140. /******************************************************************************
  141.  NAME
  142.    ANend - End annotation access to file file
  143.  
  144.  DESCRIPTION
  145.    End annotation access to file.
  146.  
  147.  RETURNS
  148.    SUCCEED if successful and  FAIL otherwise.
  149. *******************************************************************************/
  150. extern int32 ANend(int32 an_id /* IN: Annotation ID of file to close */);
  151.  
  152. /******************************************************************************
  153.  NAME
  154.    ANcreate - create a new element annotation and return a handle(id)
  155.  
  156.  DESCRIPTION
  157.    Creates a data annotation, returns an 'an_id' to work with the new 
  158.    annotation which can either be a label or description.
  159.    Valid annotation types are AN_DATA_LABEL for data labels and 
  160.    AN_DATA_DESC for data descriptions.
  161.  
  162.  RETURNS
  163.         An ID to an annotation which can either be a label or description.
  164. *******************************************************************************/
  165. extern int32 ANcreate(int32 an_id,     /* IN: annotation interface ID */
  166.                       uint16 elem_tag, /* IN: tag of item to be assigned annotation */
  167.                       uint16 elem_ref, /* IN: reference number of itme to be assigned ann*/
  168.                       ann_type type    /* IN: annotation type */);
  169.  
  170.  
  171. /******************************************************************************
  172.  NAME
  173.     ANcreatef - create a new file annotation and return a handle(id)
  174.  
  175.  DESCRIPTION
  176.     Creates a file annotation, returns an 'an_id' to work with the new 
  177.     file annotation which can either be a label or description.
  178.     Valid annotation types are AN_FILE_LABEL for file labels and
  179.     AN_FILE_DESC for file descritpions.
  180.  
  181.  RETURNS
  182.         An ID to an annotation which can either be a file label or description
  183. *******************************************************************************/
  184. extern int32 ANcreatef(int32 an_id,  /* IN: annotation interface ID */
  185.                        ann_type type /* IN:  annotation type */);
  186.  
  187. /******************************************************************************
  188.  NAME
  189.     ANselect - get an annotation ID from index of 'type'
  190.  
  191.  DESCRIPTION
  192.     Get an annotation Id from index of 'type'.
  193.     The position index is ZERO based
  194.  
  195.  RETURNS
  196.     An ID to an annotation type which can either be a label or description 
  197. *******************************************************************************/
  198. extern int32 ANselect(int32 an_id,  /* IN: annotation interface ID */
  199.                       int32 index,  /* IN: index of annottion to get ID for */
  200.                       ann_type type /* IN: annotation type */);
  201.  
  202. /******************************************************************************
  203.  NAME
  204.    ANnumann - find number of annotation of 'type' that  match the given element tag/ref 
  205.  
  206.  DESCRIPTION
  207.    Find number of annotation of 'type' for the given element 
  208.    tag/ref pair.Should not be used for File labels and
  209.    descriptions.
  210.  
  211.  RETURNS
  212.    number of annotation found if successful and FAIL (-1) otherwise
  213.  
  214. *******************************************************************************/
  215. extern intn  ANnumann(int32 an_id,     /* IN: annotation interface id */
  216.                       ann_type type,   /* IN: annotation type */
  217.                       uint16 elem_tag, /* IN: tag of item of which this is annotation */
  218.                       uint16 elem_ref  /* IN: ref of item of which this is annotation*/);
  219.  
  220. /******************************************************************************
  221.  NAME
  222.    ANannlist - generate list of annotation ids of 'type' that match the given element tag/ref 
  223.  
  224.  DESCRIPTION
  225.    Find and generate list of annotation ids of 'type' for the given 
  226.    element tag/ref pair.Should not be used for File labels and
  227.    descriptions.
  228.  
  229.  RETURNS
  230.    number of annotations ids found if successful and FAIL (-1) otherwise
  231.  
  232. *******************************************************************************/
  233. extern intn  ANannlist(int32 an_id,     /* IN: annotation interface id */
  234.                        ann_type type,   /* IN: annotation type */
  235.                        uint16 elem_tag, /* IN: tag of item of which this is annotation */
  236.                        uint16 elem_ref, /* IN: ref of item of which this is annotation*/
  237.                        int32 ann_list[] /* OUT: array of ann_id's that match criteria.*/);
  238.  
  239. /******************************************************************************
  240.  NAME
  241.    ANannlen - get length of annotation givne annotation id
  242.  
  243.  DESCRIPTION
  244.    Uses the annotation id to find ann_key & file_id
  245.  
  246.  RETURNS
  247.    length of annotation if successful and FAIL (-1) otherwise
  248.  
  249. *******************************************************************************/
  250. extern int32 ANannlen(int32 ann_id /* IN: annotation id */);
  251.  
  252. /******************************************************************************
  253.  NAME
  254.    ANwriteann - write annotation given ann_id
  255.  
  256.  DESCRIPTION
  257.    Checks for pre-existence of given annotation, replacing old one if it
  258.    exists. Writes out annotation.
  259.  
  260.  RETURNS
  261.    SUCCEED (0) if successful and FAIL (-1) otherwise
  262.  
  263. *******************************************************************************/
  264. extern int32 ANwriteann(int32 ann_id,    /* IN: annotation id */
  265.                         const char *ann, /* IN: annotation to write */
  266.                         int32 annlen     /* IN: length of annotation*/);
  267.  
  268. /******************************************************************************
  269.  NAME
  270.    ANreadann - read annotation given ann_id
  271.  
  272.  DESCRIPTION
  273.    Gets tag and ref of annotation.  Finds DD for that annotation.
  274.    Reads the annotation, taking care of NULL terminator, if necessary.
  275.  
  276.  RETURNS
  277.    SUCCEED (0) if successful and FAIL (-1) otherwise
  278.  
  279. *******************************************************************************/
  280. extern int32 ANreadann(int32 ann_id, /* IN: annotation id (handle) */
  281.                        char *ann,    /* OUT: space to return annotation in */
  282.                        int32 maxlen  /* IN: size of space to return annotation in */);
  283.  
  284. /******************************************************************************
  285.  NAME
  286.     ANendaccess - end access to an annotation given it's id
  287.  
  288.  DESCRIPTION
  289.     Terminates access to an annotation. For now does nothing
  290.  
  291.  RETURNS
  292.     SUCCEED(0) or FAIL(-1)
  293. *******************************************************************************/
  294. extern intn  ANendaccess(int32 ann_id /* IN: annotation id */);
  295.  
  296. /******************************************************************************
  297.  NAME
  298.    ANget_tagref - get tag/ref pair for annotation based on type and index
  299.  
  300.  DESCRIPTION
  301.    Get the tag/ref of the annotation based on  the type and index of the 
  302.    annotation. The position index is zero based
  303.  
  304.  RETURNS
  305.    A tag/ref pairt to an annotation type which can either be a 
  306.    label or description.
  307.  
  308. *******************************************************************************/
  309. extern int32 ANget_tagref(int32 an_id,    /* IN: annotation interface ID */
  310.                           int32 index,    /* IN: index of annotation to get tag/ref for*/
  311.                           ann_type type,  /* IN: annotation type */
  312.                           uint16 *ann_tag,/* OUT: Tag for annotation */ 
  313.                           uint16 *ann_ref /* OUT: ref for annotation */);
  314.  
  315. /******************************************************************************
  316.  NAME
  317.    ANid2tagref -- get tag/ref given annotation id
  318.  
  319.  DESCRIPTION
  320.    Uses the annotation id to find ann_node entry which contains ann_ref
  321.  
  322.  RETURNS
  323.    SUCCEED(0) if successful and FAIL (-1) otherwise. 
  324. *******************************************************************************/
  325. extern int32 ANid2tagref(int32 ann_id,    /* IN: annotation id */
  326.                          uint16 *ann_tag, /* OUT: Tag for annotation */
  327.                          uint16 *ann_ref  /* OUT: ref for annotation */);
  328.  
  329. /******************************************************************************
  330.  NAME
  331.    ANtagref2id -- get annotation id given tag/ref
  332.  
  333.  DESCRIPTION
  334.    Gets the annotation id of the annotation given the tag/ref of
  335.    the annotation itself and the annotation interface id.
  336.  
  337.  RETURNS
  338.    Annotation id of annotation if successful and FAIL(-1) otherwise. 
  339. *******************************************************************************/
  340. extern int32 ANtagref2id(int32 an_id,    /* IN  Annotation interface id */
  341.                          uint16 ann_tag, /* IN: Tag for annotation */
  342.                          uint16 ann_ref  /* IN: ref for annotation */);
  343.  
  344. /******************************************************************************
  345.  NAME
  346.    ANatype2tag - annotation type to corresponding annotation TAG
  347.  
  348.  DESCRIPTION
  349.    Translate annotation type to corresponding TAG.
  350.  
  351.  RETURNS
  352.    Returns TAG corresponding to annotatin type.
  353. *******************************************************************************/
  354. extern uint16 ANatype2tag(ann_type atype /* IN: Annotation type */);
  355.  
  356. /******************************************************************************
  357.  NAME
  358.    ANtag2atype - annotation TAG to corresponding annotation type
  359.  
  360.  DESCRIPTION
  361.    Translate annotation TAG to corresponding atype
  362.  
  363.  RETURNS
  364.    Returns type corresponding to annotatin TAG.
  365. *******************************************************************************/
  366. extern ann_type ANtag2atype(uint16 atag /* IN: annotation tag */);
  367.  
  368.  
  369. #endif /* !MFAN_C */
  370.  
  371. #endif /* _MFAN_H */
  372.